﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 二维数组
{
    class Program
    {
        static void Main(string[] args)
        {
            // 二维数组的定义
            int[,] a = new int[3, 4];

            //1.
            int[,] a1 = new int[2, 3] { {1, 2, 3}, {4, 5, 6} };
            //2.
            int[,] a2 = new int[,] { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12} };
            //3.静态
            int[,] a3 = { {2, 3}, {3, 5} };

            Console.WriteLine(a1[1, 2]);
            Console.WriteLine(a2[0, 3]);
            //Console.WriteLine(a.Length);
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    a[i, j] = a2[i, j] * 2;
                    //Console.Write("{0}\t", a[i, j]);
                }
            }

            // 把a当中的行和列交换，存到另一个数组当中（4行3列）
            int[,] a4 = new int[4, 3];
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    a4[i, j] = a[j, i];
                    Console.Write("{0}\t", a4[i, j]);
                }
                Console.WriteLine();
            }

            int[,] a5 = new int[,] { { 10, 22, 13, 24 }, { 35, 76, 17, 8 }, { 29, 14, 71, 42 } };
            int max = 0;
            int indexX = 0;
            int indexY = 0;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (a5[i,j] > max)
                    {
                        max = a5[i, j];
                        indexX = i + 1;
                        indexY = j + 1;
                    }
                }
            }
            Console.WriteLine(max);
            Console.WriteLine(indexX);
            Console.WriteLine(indexY);
        }
    }
}
